package res;
import org.newdawn.slick.opengl.Texture;

public class GLResourceLoader 
{
    public static Texture loadTexture(String tex)
    {
	String[] buff = tex.split("\\.");
	if(buff.length!=2)
	{
	    System.err.println("Invalid file\n");
	    return null;
	}
	Texture texture = null;
	try
	{
	    texture = org.newdawn.slick.opengl.TextureLoader.getTexture(buff[1].toUpperCase(), GLResourceLoader.class.getResourceAsStream("img/" + tex));
	}
	catch (Exception e) 
	{
	    try
	    {
		texture = org.newdawn.slick.opengl.TextureLoader.getTexture(buff[1].toUpperCase(), GLResourceLoader.class.getResourceAsStream(tex));
	    }
	    catch (Exception e2) 
	    {
		e.printStackTrace();
		e2.printStackTrace();
	    }
	}
	return texture;
    }
}
